
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>组件样式 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="dynamic.html" />
    
    
    <link rel="prev" href="component.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Angular-cli/">
            
                <a href="../Angular-cli/">
            
                    
                    Angular-cli
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Angular-cli/Angular-cli.html">
            
                <a href="../Angular-cli/Angular-cli.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Angular-cli/restMenu.html">
            
                <a href="../Angular-cli/restMenu.html">
            
                    
                    初始结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../architecture/">
            
                <a href="../architecture/">
            
                    
                    架构
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../architecture/mo-kuai.html">
            
                <a href="../architecture/mo-kuai.html">
            
                    
                    模块简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../architecture/component.html">
            
                <a href="../architecture/component.html">
            
                    
                    组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../architecture/Service.html">
            
                <a href="../architecture/Service.html">
            
                    
                    服务与依赖注入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    组件与模板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="zu-jian-yu-mo-ban.html">
            
                <a href="zu-jian-yu-mo-ban.html">
            
                    
                    数据显示与模板语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="cycle.html">
            
                <a href="cycle.html">
            
                    
                    生命周期钩子
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="component.html">
            
                <a href="component.html">
            
                    
                    组件交互
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.4" data-path="style.html">
            
                <a href="style.html">
            
                    
                    组件样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="dynamic.html">
            
                <a href="dynamic.html">
            
                    
                    动态组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="directive.html">
            
                <a href="directive.html">
            
                    
                    属性指令与结构指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="pipeAndAnimit.html">
            
                <a href="pipeAndAnimit.html">
            
                    
                    管道与动画
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../router/">
            
                <a href="../router/">
            
                    
                    路由与导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../form/">
            
                <a href="../form/">
            
                    
                    表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../http/">
            
                <a href="../http/">
            
                    
                    请求http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../project/">
            
                <a href="../project/">
            
                    
                    项目解析:结构目录
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >组件样式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x7EC4;&#x4EF6;&#x6837;&#x5F0F;">&#x7EC4;&#x4EF6;&#x6837;&#x5F0F;</h3>
<p>&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;&#x4E4B;&#x4E00;&#xFF0C;&#x662F;&#x5728;&#x7EC4;&#x4EF6;&#x7684;&#x5143;&#x6570;&#x636E;&#x4E2D;&#x8BBE;&#x7F6E; <code>styles</code> &#x5C5E;&#x6027;&#x3002; <code>styles</code> &#x5C5E;&#x6027;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x5305;&#x542B; <code>CSS</code> &#x4EE3;&#x7801;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x6570;&#x7EC4;&#x3002; &#x901A;&#x5E38;&#x4F60;&#x53EA;&#x7ED9;&#x5B83;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x5C31;&#x884C;&#x4E86;&#xFF0C;&#x5982;&#x540C;&#x4E0B;&#x4F8B;&#xFF1A;</p>
<p> <img src="../assets/css1.png" alt=""></p>
<p> &#x5728; <code>@Component</code> &#x7684;&#x5143;&#x6570;&#x636E;&#x4E2D;&#x6307;&#x5B9A;&#x7684;&#x6837;&#x5F0F;&#x53EA;&#x4F1A;&#x5BF9;&#x8BE5;&#x7EC4;&#x4EF6;&#x7684;&#x6A21;&#x677F;&#x751F;&#x6548;&#x3002;</p>
<p> &#x8FD9;&#x79CD;&#x8303;&#x56F4;&#x9650;&#x5236;&#x5C31;&#x662F;&#x6240;&#x8C13;&#x7684;&#x6837;&#x5F0F;&#x6A21;&#x5757;&#x5316;&#x7279;&#x6027;</p>
<ul>
<li><p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5BF9;&#x6BCF;&#x4E2A;&#x7EC4;&#x4EF6;&#x6700;&#x6709;&#x610F;&#x4E49;&#x7684; CSS &#x7C7B;&#x540D;&#x548C;&#x9009;&#x62E9;&#x5668;&#x3002;</p>
</li>
<li><p>&#x7C7B;&#x540D;&#x548C;&#x9009;&#x62E9;&#x5668;&#x662F;&#x4EC5;&#x5C5E;&#x4E8E;&#x7EC4;&#x4EF6;&#x5185;&#x90E8;&#x7684;&#xFF0C;&#x5B83;&#x4E0D;&#x4F1A;&#x548C;&#x5E94;&#x7528;&#x4E2D;&#x5176;&#x5B83;&#x5730;&#x65B9;&#x7684;&#x7C7B;&#x540D;&#x548C;&#x9009;&#x62E9;&#x5668;&#x51FA;&#x73B0;&#x51B2;&#x7A81;&#x3002;</p>
</li>
<li><p>&#x7EC4;&#x4EF6;&#x7684;&#x6837;&#x5F0F;&#x4E0D;&#x4F1A;&#x56E0;&#x4E3A;&#x522B;&#x7684;&#x5730;&#x65B9;&#x4FEE;&#x6539;&#x4E86;&#x6837;&#x5F0F;&#x800C;&#x88AB;&#x610F;&#x5916;&#x6539;&#x53D8;&#x3002;</p>
</li>
<li><p>&#x4F60;&#x53EF;&#x4EE5;&#x8BA9;&#x6BCF;&#x4E2A;&#x7EC4;&#x4EF6;&#x7684; CSS &#x4EE3;&#x7801;&#x548C;&#x5B83;&#x7684; TypeScript&#x3001;HTML &#x4EE3;&#x7801;&#x653E;&#x5728;&#x4E00;&#x8D77;&#xFF0C;&#x8FD9;&#x5C06;&#x4FC3;&#x6210;&#x6E05;&#x723D;&#x6574;&#x6D01;&#x7684;&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x3002;</p>
</li>
<li><p>&#x5C06;&#x6765;&#x4F60;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;&#x6216;&#x79FB;&#x9664;&#x7EC4;&#x4EF6;&#x7684; CSS &#x4EE3;&#x7801;&#xFF0C;&#x800C;&#x4E0D;&#x7528;&#x904D;&#x5386;&#x6574;&#x4E2A;&#x5E94;&#x7528;&#x6765;&#x770B;&#x5B83;&#x6709;&#x6CA1;&#x6709;&#x88AB;&#x522B;&#x5904;&#x7528;&#x5230;&#xFF0C;&#x53EA;&#x8981;&#x770B;&#x770B;&#x5F53;&#x524D;&#x7EC4;&#x4EF6;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</p>
<p>&#x6A21;&#x677F;&#x5185;&#x8054;&#x6837;&#x5F0F; </p>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;&#x7EC4;&#x4EF6;&#x7684; HTML &#x6A21;&#x677F;&#x4E2D;&#x5D4C;&#x5165; <code>&lt;style&gt;</code> &#x6807;&#x7B7E;</p>
<pre><code> @Component({
   selector: &apos;app-hero-controls&apos;,
   template: `
     &lt;style&gt;
       button {
         background-color: white;
         border: 1px solid #777;
       }
     &lt;/style&gt;
     &lt;h3&gt;Controls&lt;/h3&gt;
     &lt;button (click)=&quot;activate()&quot;&gt;Activate&lt;/button&gt;
   `
 })
</code></pre></li>
</ul>
<p>&#x6A21;&#x677F;&#x4E2D;&#x7684; link &#x6807;&#x7B7E;</p>
<pre><code>    @Component({
      selector: &apos;app-hero-team&apos;,
      template: `
        &lt;!-- We must use a relative URL so that the AOT compiler can find the stylesheet --&gt;
        &lt;link rel=&quot;stylesheet&quot; href=&quot;../assets/hero-team.component.css&quot;&gt;
        &lt;h3&gt;Team&lt;/h3&gt;
        &lt;ul&gt;
          &lt;li *ngFor=&quot;let member of hero.team&quot;&gt;

          &lt;/li&gt;
        &lt;/ul&gt;`
    })
</code></pre><p>CSS @imports &#x8BED;&#x6CD5;</p>
<p>&#x4F60;&#x8FD8;&#x53EF;&#x4EE5;&#x5229;&#x7528;&#x6807;&#x51C6;&#x7684; CSS @import &#x89C4;&#x5219;&#x6765;&#x628A;&#x5176;&#x5B83; CSS &#x6587;&#x4EF6;&#x5BFC;&#x5165;&#x5230; CSS &#x6587;&#x4EF6;&#x4E2D;&#x3002;</p>
<p>&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;URL &#x662F;&#x76F8;&#x5BF9;&#x4E8E;&#x4F60;&#x6B63;&#x5728;&#x5BFC;&#x5165;&#x7684; CSS &#x6587;&#x4EF6;&#x7684;</p>
<pre><code>    @import &apos;./hero-details-box.css&apos;;
</code></pre><p>&#x975E; CSS &#x6837;&#x5F0F;&#x6587;&#x4EF6;</p>
<p>&#x4F7F;&#x7528; CLI &#x8FDB;&#x884C;&#x6784;&#x5EFA;&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x53EF;&#x4EE5;&#x7528; sass&#x3001;less &#x6216; stylus &#x6765;&#x7F16;&#x5199;&#x6837;&#x5F0F;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;&#x76F8;&#x5E94;&#x7684;&#x6269;&#x5C55;&#x540D;&#xFF08;.scss&#x3001;.less&#x3001;.styl&#xFF09;&#x628A;&#x5B83;&#x4EEC;&#x6307;&#x5B9A;&#x5230; @Component.styleUrls &#x5143;&#x6570;&#x636E;&#x4E2D;&#x3002;&#x4F8B;&#x5B50;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>    @Component({
      selector: &apos;app-root&apos;,
      templateUrl: &apos;./app.component.html&apos;,
      styleUrls: [&apos;./app.component.scss&apos;]
    })
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="component.html" class="navigation navigation-prev " aria-label="Previous page: 组件交互">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="dynamic.html" class="navigation navigation-next " aria-label="Next page: 动态组件">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"组件样式","level":"1.4.4","depth":2,"next":{"title":"动态组件","level":"1.4.5","depth":2,"path":"comAndtem/dynamic.md","ref":"comAndtem/dynamic.md","articles":[]},"previous":{"title":"组件交互","level":"1.4.3","depth":2,"path":"comAndtem/component.md","ref":"comAndtem/component.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["fontsettings","sharing","lunr","search","highlight","livereload"],"pluginsConfig":{"fontsettings":{"family":"sans","size":2,"theme":"white"},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"lunr":{"ignoreSpecialCharacters":false,"maxIndexSize":1000000},"search":{},"highlight":{},"livereload":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"comAndtem/style.md","mtime":"2018-06-15T03:34:40.377Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-06-29T06:02:19.129Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    

    </body>
</html>

